package sf_time

import (
	"engine/cache"
	"fmt"
	"github.com/gin-gonic/gin"
	"time"
)

/*
矿石卖出私聊  ks_sl
参加抢地主   dz_tz
参加抢私饲料   sl_sl
PK   pk_tz
爬塔   pt_tz
*/
func SetRedisKey(ctx *gin.Context, keys string, addNum float64) {

	var zongc float64
	mm, _ := cache.RedisContextGet[float64](ctx, keys)
	if mm != nil {
		zongc = *mm
	}

	ccc := fmt.Sprintf("%s_%s", keys, time.Now().Format("20060102"))
	var jinci float64
	mm, _ = cache.RedisContextGet[float64](ctx, ccc)
	if mm != nil {
		jinci = *mm
	}

	zongc += addNum
	jinci += addNum
	cache.RedisContextSet(ctx, keys, zongc, 0)
	cache.RedisContextSet(ctx, ccc, jinci, 32*time.Hour)
	return
}
